/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.deepplin.mongodbmanager.form;

import java.util.List;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;

import com.deepplin.mongodbmanager.MongoDBManager;
import com.deepplin.mongodbmanager.control.MongoDBController;

/**
*
* @author 정보원3계
*/
public class MongoDBManagerFrm extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private MongoDBManager mgManager = null;
	private MongoDBController mgController = null;
	
   /**
    * Creates new form MongoDBManagerFrm
    */
   public MongoDBManagerFrm() {
       initComponents();
   }

   public void init( MongoDBManager mgManager){
	   this.mgManager = mgManager;
	   mgController = MongoDBController.getInstance();  
   }
   
   /**
    * 
    */
   public void start(){
	   if( mgController.checkConnection() == false){
		   this.mgManager.runLogin(true);
	   }
   }
   
   public void setDBList( List<String> listDB){
	   DefaultMutableTreeNode treeNodeRoot = new DefaultMutableTreeNode("DB");
	   for (String string : listDB) {
		   DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(string);
		   treeNodeRoot.add(treeNode);
	   }
	   this.treeDBList.setModel( new  DefaultTreeModel( treeNodeRoot));
	    
   }   


/**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
   private void initComponents() {

       jSplitPane1 = new javax.swing.JSplitPane();
       jPanel1 = new javax.swing.JPanel();
       jSplitPane2 = new javax.swing.JSplitPane();
       jPanel3 = new javax.swing.JPanel();
       jScrollPane1 = new javax.swing.JScrollPane();
       treeDBList = new javax.swing.JTree();
       jPanel4 = new javax.swing.JPanel();
       jScrollPane2 = new javax.swing.JScrollPane();
       tableProperties = new javax.swing.JTable();
       jPanel2 = new javax.swing.JPanel();
       jScrollPane3 = new javax.swing.JScrollPane();
       tableDocuments = new javax.swing.JTable();
       jButton2 = new javax.swing.JButton();
       jButton4 = new javax.swing.JButton();

       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

       jSplitPane1.setDividerLocation(200);

       jPanel1.setLayout(new java.awt.BorderLayout());

       jSplitPane2.setDividerLocation(200);
       jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

       jPanel3.setLayout(new java.awt.BorderLayout());

       jScrollPane1.setViewportView(treeDBList);

       jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);

       jSplitPane2.setTopComponent(jPanel3);

       jPanel4.setLayout(new java.awt.BorderLayout());

       tableProperties.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {
               {null, null, null, null},
               {null, null, null, null},
               {null, null, null, null},
               {null, null, null, null}
           },
           new String [] {
               "Title 1", "Title 2", "Title 3", "Title 4"
           }
       ));
       jScrollPane2.setViewportView(tableProperties);

       jPanel4.add(jScrollPane2, java.awt.BorderLayout.CENTER);

       jSplitPane2.setRightComponent(jPanel4);

       jPanel1.add(jSplitPane2, java.awt.BorderLayout.CENTER);

       jSplitPane1.setLeftComponent(jPanel1);

       jPanel2.setLayout(new java.awt.BorderLayout());

       tableDocuments.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {
               {null, null, null, null},
               {null, null, null, null},
               {null, null, null, null},
               {null, null, null, null}
           },
           new String [] {
               "Title 1", "Title 2", "Title 3", "Title 4"
           }
       ));
       tableDocuments.setEnabled(false);
       jScrollPane3.setViewportView(tableDocuments);

       jPanel2.add(jScrollPane3, java.awt.BorderLayout.CENTER);

       jSplitPane1.setRightComponent(jPanel2);

       jButton2.setText("jButton2");

       jButton4.setText("jButton4");

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                   .addGroup(layout.createSequentialGroup()
                       .addComponent(jButton2)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(jButton4)
                       .addGap(0, 422, Short.MAX_VALUE)))
               .addContainerGap())
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jButton2)
                   .addComponent(jButton4))
               .addGap(12, 12, 12)
               .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
               .addContainerGap())
       );

       pack();
   }// </editor-fold>                        

   
   // Variables declaration - do not modify                     
   private javax.swing.JButton jButton2;
   private javax.swing.JButton jButton4;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JPanel jPanel2;
   private javax.swing.JPanel jPanel3;
   private javax.swing.JPanel jPanel4;
   private javax.swing.JScrollPane jScrollPane1;
   private javax.swing.JScrollPane jScrollPane2;
   private javax.swing.JScrollPane jScrollPane3;
   private javax.swing.JSplitPane jSplitPane1;
   private javax.swing.JSplitPane jSplitPane2;
   private javax.swing.JTable tableProperties;
   private javax.swing.JTable tableDocuments;
   private javax.swing.JTree treeDBList;
   // End of variables declaration                   
}
